﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ADL;
using CDIO.Models;

namespace CDIO.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public HomeModel model = null;

        public ActionResult Index(string username)
        {
            ViewBag.Message = username;

            ADL_user ad_us = new ADL_user();
            _user us = new _user();
            List<_user> listuse = ad_us.search(null, "*");

            ADL_gift ad_gi = new ADL_gift();
            _gift gi = new _gift();
            List<_gift> listgi = ad_gi.search(null, "*");

            ADL_record ad_re = new ADL_record();
            _record re = new _record();
            List<_record> listre = ad_re.search(null, "*");

            int useraccount = listuse.Count;
            int giftaccount = listgi.Count;
            int getaccount  = listre.Count;


            if (listuse != null)
            {
                model = new HomeModel
                {
                    useraccount = "" + useraccount,
                    getaccount = "" + getaccount,
                    giftaccount = "" + giftaccount
                };
            }
            return View(model);
        }
    }
}
